<?php
/**
 * Pipahr
 *
 * @author Chin Win
 * @copyright 2013 pipahr.com
 */
OCP\JSON::checkAppEnabled('resumes');
OCP\JSON::callCheck();
if(!OC_User::isLoggedIn()) {
   echo '您需要先登录';
   exit;
}

$userQuota = PCompanyHelper::getUserQuota();
$sms_left = $userQuota['sms_left'];

$jobseekername = JRequest::getString("jobseekername", "");
$jobseekerid = JRequest::getInt("jobseekerid", 0);
$jobtitle = JRequest::getString("jobtitle", "");
$jobid = JRequest::getInt("jobid", 0);
$validemail = JRequest::getInt("validemail", 0);

echo '
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>邀请评测</h3>
   </div>
   <div class="modal-body" id="">
      <div class="form-horizontal onlineinter_testbody medium">
         <div style="margin-bottom:4px;" class="control-group">
            <label for="" class="control-label">姓<i class="jiange"></i>名：</label>
            <div style="margin-left:4px; margin-right:30px;" class="controls pull-left">
               <span>
                  <a target="_blank" id="" href="' . OCP\Util::linkToRoute('resume_view', array('id' => $jobseekerid, 'name' => $jobseekername)) . '">' . $jobseekername . '</a>
               </span>
            </div>
            <label for="" class="control-label">职<i class="jiange"></i>位：</label>
            <div style="margin-left:4px;" class="controls pull-left">
               <span>
                  <a target="_blank" id="" href="' . OC_Helper::linkToRoute("jobpos_setup", array('id'=>$jobid, 'job_title'=>isset($jobtitle) ? $jobtitle : '')) . '">' . $jobtitle . '</a>
               </span>
            </div>
         </div>

         <div style="margin-bottom:4px;" class="control-group">
            <label for="" class="control-label"><em class="redstar">* </em>发送设置：</label>
            <div style="margin-left:84px;" class="controls">';
               if(empty($validemail)) {
                  echo '<label class="checkbox medium gray inline" id="sendemaillabel"'.($sms_left > 0 ? 'title="简历缺少Email信息"' : '').'>
                     <input type="checkbox" id="sendemail" name="sendemail" value="email" disabled="disabled">Email
                  </label>';
               } else {
                  echo '<label class="checkbox medium inline">
                     <input type="checkbox" id="sendemail" name="sendemail" value="email" disabled="disabled" checked>Email
                  </label>';
               }
               if($sms_left > 0 ) {
                  echo '<label class="checkbox medium inline">';
                     if($userQuota['email_sms_settings']['sms_onlineinterview_0h']) {
                        echo '<input type="checkbox" id="sendsms" name="sendsms" value="sms" checked>手机短信(<em>剩余' . $sms_left . '条</em>)';
                     } else {
                        echo '<input type="checkbox" id="sendsms" name="sendsms" value="">手机短信(<em>剩余' . $sms_left . '条</em>)';
                     }
                  echo '</label>';
               } else {
                  echo '<label class="checkbox medium gray inline">
                     <input type="checkbox" id="sendsms" name="send" value="sms" disabled="disabled">手机短信(剩余0条) <a href="' . OC_Helper::linkToRoute('company_quota') . '" class="buymessage">立即购买</a>
                  </label>';
               }
            echo '
            </div>
         </div>

         <div style="margin-top:14px;" class="control-group">
            <label for="" class="control-label"></label>
            <div style="margin-left:84px;" class="controls clearfix">';
            
            if(empty($validemail) && ($sms_left <= 0 || empty($userQuota['email_sms_settings']['sms_onlineinterview_0h']))) {
               echo '<a href="javascript:;" id="onlineinter_button" class="ppp_graybtn pull-right" style="cursor:default;">发送</a>';
            } else {
               echo '<a href="javascript:;" id="onlineinter_button" class="ppp_bluebtn pull-right">发送</a>';
            }
            echo "
            </div>
         </div>
      </div>
   </div>";
